/*
cap program drop mypath
program define mypath, rclass
version 15.0
  syntax, Folder(string) [pwd(string) Subfolders(string) NOABB NOLIST] //Abbsubfolders(string)
  if `"`pwd'"'==""{
    local pwd: pwd
    * dis "`pwd'"  
  }
  else{
    local pwd `"`pwd'"'
  }
  
  cd `"`pwd'"'
  if `"`folder'"'!=""{
    cap mkdir `folder'
	qui cd `pwd'/`folder'
  }
 
  if `"`subfolders'"'==""{
    local subfolders "data refs out adofiles"
  }
  
  if "`nolist'"==""{
    dis "macro list: "
  }
  local pwd: pwd
  foreach f of local subfolders{
    cap mkdir `f'
	global `f' `"`pwd'/`f'"'
	if "`nolist'"==""{
	  dis  "    $" "`f': " "$`f'"
	  dis `"global `f' `"`pwd'/`f'"' "'
	}
  }

end

* test

tr: 
mypath , pwd(D:\stata15\ado\personal\CF10) f(test7)
*/



*-----------------------------------------
*! 2018/9/8 11:50
*! Given by Yujun Lian 
cap program drop mypath
program define mypath, rclass
version 15.0

  syntax, Folder(string) [Path(string)] //Abbsubfolders(string)
  local pwd: pwd
  if `"`path'"'==""{ 
	local path `"`pwd'"'
  }
  
  cd `"`path'"'
  if `"`folder'"'!=""{
    qui cap mkdir `folder'
	qui cd `path'/`folder'
  }
 
  if `"`subfolders'"'==""{
    local subfolders "data refs out adofiles"
  }
  
  local pwd: pwd
  foreach f of local subfolders{
    qui cap mkdir `f'
	global `f' `"`pwd'/`f'"'
/*
	if "`nolist'"==""{
	  dis  "    $" "`f': " "$`f'"
	  dis `"global `f' `"`pwd'/`f'"' "'
	}
*/

  }

 dis `"global path "`path'/`folder'" //定义课程目录"'
 dis `"global path "\`c(sysdir_personal)'/`folder'" //定义课程目录"'	
 dis `"global D    "$path\data"      //范例数据"'
 dis `"global R    "$path\refs"      //参考文献"'
 dis `"global Out  "$path\out"       //结果：图形和表格"'
 dis `"adopath +   "$path\adofiles"  //自编程序 "'
 dis `"cd "\$D""'
 dis `"set scheme s2color //彩色 "'
 dis `"set scheme s1mono  //黑白 "'
 dis `""'
 dis `"/*"'
 dis `"ssc install scheme_tufte, replace //tufte 模板"'
 dis `"set scheme tufte"'
 dis `"*/"'  
  
/*
preserve  
  clear all
  input str50 x 
  `"global path "`pwd'/`folder'" //定义课程目录"'
  `"global path "`c(sysdir_personal)'\`folder'" //定义课程目录"'	
  `"global D    "$path\data"      //范例数据"'
  `"global R    "$path\refs"      //参考文献"'
  `"global Out  "$path\out"       //结果：图形和表格"'
  `"adopath +   "$path\adofiles"  //自编程序 "'
  `"cd "$D""'
  `"set scheme s2color //彩色 "'
  `"set scheme s1mono  //黑白 "'
  `""'
  `"/*"'
  `"ssc install scheme_tufte, replace //tufte 模板"'
  `"set scheme tufte"'
  `"*/"'
  end 

  format x %-50s
  list x, clean noobs noheader
restore  
*/

end


tr:///
mypath , path(D:\stata15\ado\personal\CF10) f(test9)
